<script setup>
import { ref, toRaw } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import Type from '@components/search/type'
import Search from '@components/search/index'
import PageWrapper from '@components/PageWrapper.vue'
import { common, service } from '@utils'
import { Plus, Edit, View } from '@element-plus/icons-vue'
import { usePremission, useRole } from '@hooks'

const premission = usePremission()

const searchs = ref([
    {
        type: Type.INPUT,
        key: 'path',
        width: 5,
        placeholder: '菜单路径'
    },
    {
        type: Type.INPUT,
        key: 'actions',
        width: 5,
        placeholder: '类型'
    },
    {
        type: Type.INPUT,
        key: 'level',
        width: 5,
        placeholder: '级别'
    },
    {
        width: 6,
        type: Type.SEARCH_BUTTON
    }
])

const pageRef = ref()
const tableRef = ref()

let queryForm = {}

const onSearch = (param) => {
    queryForm = param
    pageRef.value.refresh()
}

const getData = async ({ pageNum, pageSize }, cb) => {
    const res = await service.monitor.logs(pageNum, pageSize, queryForm.search)
    cb(res)
    setTimeout(() => {
        tableRef.value.scrollTo(0, 0)
    }, 0)
}
</script>
    <template>
    <section class="main-white">
        <search :items="searchs" @filter="onSearch" />
        <page-wrapper @get-data="getData" ref="pageRef">
            <template v-slot:default="props">
                <vxe-table ref="tableRef" :loading="props.loading" :data="props.tableData.records" :max-height="common.tableHeight(true, 1)"
                    highlight-hover-row round stripe border>
                    <vxe-column field="createDate" title="时间" width="170" />
                    <vxe-column field="createUser" title="操作人" />
                    <vxe-column field="path" title="菜单路径" />
                    <vxe-column field="actions" title="类型" />
                    <vxe-column field="level" title="级别" />
                    <vxe-column field="lei" title="类" />
                    <vxe-column field="result" title="结果" />
                </vxe-table>
            </template>
        </page-wrapper>
    </section>
</template>